unit prSHYBTSECheck;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, uClassReport, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit,
  cxPCdxBarPopupMenu, cxStyles, cxCustomData, cxFilter, cxData, cxDataStorage,
  Data.DB, cxDBData, Vcl.Menus, Data.Win.ADODB, Vcl.ImgList, Vcl.ActnList,
  cxPropertiesStore, Vcl.StdCtrls, cxButtons, cxGridLevel, cxClasses,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, cxPC, cxGroupBox, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox, cxSpinEdit, cxHeader;

type
  TfmSHYBTSECheck = class(TfmClassReport)
    aqSHYBActionList: TADOQuery;
    dsSHYBActionList: TDataSource;
    Label6: TLabel;
    lcSHYBActList: TcxLookupComboBox;
    aqTSEActionList: TADOQuery;
    dsTSEActionList: TDataSource;
    Label1: TLabel;
    lcTSEActList: TcxLookupComboBox;
    Label5: TLabel;
    seLimit: TcxSpinEdit;
    Label7: TLabel;
    edUnvan: TcxTextEdit;
    Label2: TLabel;
    lcTseNo: TcxLookupComboBox;
    aqTseNo: TADOQuery;
    dsTseNo: TDataSource;
    grdReportssID: TcxGridDBColumn;
    grdReportsYeterlilikNo: TcxGridDBColumn;
    grdReportsUnvan: TcxGridDBColumn;
    grdReportTseNo: TcxGridDBColumn;
    grdReportTSE_FirmaAdet: TcxGridDBColumn;
    grdReportSHYB_FirmaAdet: TcxGridDBColumn;
    grdReportGereken: TcxGridDBColumn;
    grdReportFark: TcxGridDBColumn;
    grdReportOnay: TcxGridDBColumn;
    grdReportGecerlilik: TcxGridDBColumn;
    grdReportKalanGun: TcxGridDBColumn;
    pmDetay: TPopupMenu;
    miDetayGoster: TMenuItem;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure acListExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure miDetayGosterClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmSHYBTSECheck: TfmSHYBTSECheck;

implementation

uses Data, prSHYBTSECheckDetay;
{$R *.dfm}

procedure TfmSHYBTSECheck.acListExecute(Sender: TObject);
var
  ExCursor: TCursor;
begin
  inherited;
  if lcSHYBActList.Text = '' then
  begin
    ShowMessage('SHYB Action Grubunu Giriniz!');
    lcSHYBActList.SetFocus;
    Exit;
  end;

  if lcTSEActList.Text = '' then
  begin
    ShowMessage('TSE Action Grubunu Giriniz!');
    lcTSEActList.SetFocus;
    Exit;
  end;

  ExCursor := Screen.Cursor;
  Screen.Cursor := crSQLWait;
  try
    with aqList do
    begin
      Close;
      SQL.Text := 'EXEC SP_FIRMAYAKALA @ActionGrupTSE=:ActionGrupTSE,@ActionGrupSHYB=:ActionGrupSHYB,@UnvanLimit=:UnvanLimit,@TseNo=:TseNo,@Unvan=:Unvan';
      Parameters.ParamByName('ActionGrupTSE').Value := lcTSEActList.EditValue;
      Parameters.ParamByName('ActionGrupSHYB').Value := lcSHYBActList.EditValue;
      Parameters.ParamByName('UnvanLimit').Value := seLimit.Value;
      Parameters.ParamByName('TseNo').Value := lcTseNo.EditValue;
      Parameters.ParamByName('Unvan').Value := edUnvan.Text;
      Open;
    end;
  finally
    Screen.Cursor := ExCursor;
  end;
end;

procedure TfmSHYBTSECheck.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  inherited;
  Action := caFree;
  fmSHYBTSECheck := nil;
end;

procedure TfmSHYBTSECheck.FormCreate(Sender: TObject);
begin
  inherited;
  aqSHYBActionList.Close;
  aqSHYBActionList.Open;

  aqTSEActionList.Close;
  aqTSEActionList.Open;

  aqTseNo.Close;
  aqTseNo.Open;
end;

procedure TfmSHYBTSECheck.miDetayGosterClick(Sender: TObject);
var
  Unvan: String;
begin
  inherited;
  if (aqList.Active) and (aqList.RecordCount > 0) then
  begin
    fmSHYBTSECheckDetay := TfmSHYBTSECheckDetay.Create(Self);
    fmSHYBTSECheckDetay.lcTSEActList.EditValue := lcTSEActList.Text;
    fmSHYBTSECheckDetay.lcSHYBActList.EditValue := lcSHYBActList.Text;
    fmSHYBTSECheckDetay.edUnvan.Text := aqList.FieldByName('sUnvan').AsString;
    fmSHYBTSECheckDetay.lcTseNo.EditValue := lcTseNo.Text;
    fmSHYBTSECheckDetay.seLimit.Value := seLimit.Value;
    fmSHYBTSECheckDetay.btReport.Click;
  end;
end;

end.
